package Threading;

public class demo9 {
    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread(()->{
            for (int i = 0; i < 1000; i++) {
                ;
            }
            try {
                Thread.sleep(2000);
            } catch (InterruptedException e) {
                e.getStackTrace();
            }
        });
        //还没有调用start故属于NEW状态
        System.out.println(t.getState());

        t.start();
        //线程正在运行的状态RUNNABLE
        System.out.println(t.getState());

        Thread.sleep(1000);
        //线程在一定时间内阻塞的状态TIMED_WAITING
        System.out.println(t.getState());

        t.join();
        //线程运行完，但是Thread对象还在的状态TERMINATED
        System.out.println(t.getState());
    }
}
